
//
//  Converter.swift
//  Algorithms
//
//  Created by Archer on 2018/8/4.
//  Copyright © 2018年 Archer. All rights reserved.
//

import Foundation

extension Bool {
    func toInt() -> Int {
        return (self == true) ? 1 : 0
    }
    
    func toDouble() -> Double {
        return toInt().toDouble()
    }
}

extension Int {
    func toBool() -> Bool {
        return self != 0
    }
    
    func toDouble() -> Double {
        return Double(self)
    }
}

extension Double {
    func toBool() -> Bool {
        return self != 0
    }
    
    func toInt() -> Int {
        return Int(self)
    }
}
